<!--  -->
<template>
  <div class='gift-page'>
    <c-title :hide="false" :text="packageTitle"></c-title>
    <div class="gift-content">
      <div class="banner" ref="banner">
        <van-swipe
          :autoplay="3000"
          :loop="false"
          indicator-color="var(--themeBaseColor)"
          class="my-swipe"
          :width="fun.getPhoneEnv() == 3 ? 375 : clientWidths"
        >
          <van-swipe-item v-for="(item, index) in carousels" :key="index">
            <a :href="item.carousel_link" v-if="item.carousel_link">
              <img :src="item.carousel_thumb" alt="" />
            </a>
            <a  v-else>
              <img :src="item.carousel_thumb" alt="" />
            </a>
          </van-swipe-item>
        </van-swipe>
      </div>
      <template v-if="!giftInfo.page_template">
        <div class="content_a">
          <div class="rob-time" v-if="timeStatus">
            <div class="img">
              <img src="../../../assets/images/rob-time.png" width="16%;" />
            </div>
            <ul class="price">
              <li class="text">
                <span>限时<br />购买</span>
              </li>
            </ul>
            <div class="time">
              <span class="text">截至倒计时：</span>
              <van-count-down :time="fun.getTimeDifference(fun.getTimestamp(endTimeStr))" class="bottom_time" format="DD天HH时mm分ss秒" @finish="salePriceTime">
                <template #default="timeData">
                  <em style="padding: 0.125rem; border-radius: 0.125rem;"
                    >{{ timeData.days <10 ? `0${timeData.days}` :timeData.days}}</em
                  >天
                  <em style="padding: 0.125rem; border-radius: 0.125rem;"
                    >{{ timeData.hours <10 ? `0${timeData.hours}` :timeData.hours}}
                  </em>
                  <b>:</b>
                  <em style="padding: 0.125rem; border-radius: 0.125rem;"
                    >{{ timeData.minutes <10 ? `0${timeData.minutes}` :timeData.minutes}}
                  </em>
                  <b>:</b>
                  <em style="padding: 0.125rem; border-radius: 0.125rem;"
                    >{{ timeData.seconds <10 ? `0${timeData.seconds}` :timeData.seconds}}
                  </em>
                </template>
              </van-count-down>
            </div>
          </div>
        </div>
        <div class="header-main" ref="headerMain">
          <h3 class="ell">{{packageTitle}}</h3>
          <div class="header-desc ">
            <div class="flex-a-c flex-j-sb">
              <div class="header-user flex-a-c">
                <img :src="giftInfo.description_thumb" />
                <h3 class="ell">{{giftInfo.description_title}}</h3>
              </div>
              <div class="symbol flex-a-c">
                <span class="iconfont icon-yinhao"></span>
              </div>
            </div>
            <div class="detail">{{giftInfo.description_desc}}</div>
          </div>
        </div>
      </template>
      <div class="mb-10"></div>
      <div class="goods-List" @click="gogoodsDetailBtn">
        <div class="flex">
          <div class="goods-info">
            <div class="info_a" >
            <div class="img" >
              <van-image
                width="96px"
                height="96px"
                radius="8px"
                :src="giftInfo.thumb"
              />
              </div>
              <ul class="info">
                <li class="name" style="-webkit-box-orient: vertical;">
                  {{ combination.combination_name }}
                </li>
                <div class="flex-j-sb price-box">
                  <li class="price" v-if="!giftInfo.page_template">
                    <span class="left"><font>{{$i18n.t('money')}}</font>{{ giftInfo.price }}</span>
                    <span class="right" v-show="parseInt(giftInfo.market_price)">{{$i18n.t('money')}}{{ giftInfo.market_price }}</span>
                  </li>
                </div>
              </ul>
            </div>
          </div>
        </div>
        <div class="goods-line" v-if="giftInfo.page_template"></div>
      </div>

      <!-- 其他推荐 -->
      <div class="content_d" v-if="otherPackages.length > 0">
        <h5>其他推荐</h5>
        <div class="d_box">
          <template v-for="(otherpitem, otherpidex) in otherPackages">
            <!--@click="gopackgoods(otherpitem.id)"-->
            <div class="goods_box"  @click="gopackgoods(otherpitem.id,otherpitem.type)" :key="otherpidex">
              <div class="img">
                <img :src="otherpitem.thumb" />
              </div>
              <ul class="info">
                <li class="info_a">{{ otherpitem.title }}</li>
                <li class="info_b">
                  推荐价：<span class="money">{{$i18n.t('money')}}</span>{{ otherpitem.price_sum }}
                </li>
              </ul>
            </div>
          </template>
        </div>
      </div>
      <div class="mb-70"></div>
      <div class="fixed" :class="giftInfo.page_template?'fixed-exchange':''">
        <p class="price" v-if="!giftInfo.page_template">
          合计：<span><span class="money">{{$i18n.t('money')}}</span>{{ giftInfo.price }}</span>
        </p>
        <button type="button" class="buyBtn" :class="giftInfo.page_template?'exchange':''"  @click="submitGoods">{{giftInfo.page_template?'立即兑换':'立即购买'}}</button>
      </div>
    </div>
  </div>
</template>

<script>
import giftIndex_controller from "./giftIndex_controller";
export default giftIndex_controller;
</script>
<style lang="scss" scoped>
/* @import url(); 引入公共css类 */
.banner ::v-deep .van-swipe__indicator {
  background-color: #fff;
  opacity: 1;
}
.van-count-down {
  color: #fff;
}
.mb-70 {
  height: 4.375rem;
  clear: both;
}
.mb-10 {
  height: 0.625rem;
  clear: both;
}
.gift-content {
  .content_a {
      background: #fff;

      .rob-time {
        display: flex;
        height: 3.0625rem;
        background-color: #f15353;

        .img {
          width: 10%;

          img {
            width: 60%;
          }
        }

        .price {
          text-align: left;
          width: 10%;
          display: flex;
          color: #fff;

          .text {
            font-size: 0.875rem;
            margin-top: 0.4375rem;
            margin-left: -0.125rem;
          }

          .none-line {
            line-height: 3.0625rem;
            font-size: 1.125rem;
            margin-left: 0.625rem;
          }

          .middle-line {
            line-height: 3.0625rem;
            font-size: 14px;
            text-decoration: line-through;
            color: #dbdbdb;
            margin-left: 0.625rem;
          }
        }

        .time {
          flex: 80%;
          text-align: left;
          line-height: 3.0625rem;
          padding-left: 1.25rem;
          display: flex;
          align-items: center;

          .text {
            font-size: 0.875rem;
            line-height: 1.5rem;
          }

          span {
            color: #fff;
            font-size: 0.875rem;
          }

          em {
            background-color: #fff;
            color: #333;
          }

          .bottom {
            margin-top: 0.125rem;
          }
        }
      }

      h1 {
        height: 2.5rem;
        line-height: 2.5rem;
        text-align: left;
        padding: 0 0.875rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 1rem;
      }
  }
  .banner {
    width: 100%;
    overflow: hidden;
    background: #f5f5f5;
    position: relative;
    // margin: 0 0 10px 0;
    img {
      width: 100%;
      display: block;
    }
  }
  .header-main {
    border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
    background: #FFFFFF;
    padding:0.75rem;
    margin:0.625rem 0.75rem 0rem 0.75rem;
    h3 {
      font-size: 1rem;
      font-weight: bold;
      color: #00001C;
      line-height: 1.25rem;
      text-align: left;
      white-space: normal;
      word-break: break-all;
    }
    .header-desc {
      border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
      padding:0.625rem 0.875rem 0.875rem 0.875rem;
      border: 0.0625rem solid #F0F0F1;
      margin:1rem 0 0 0;
      .header-user {
        width:80%;
        img {
          width: 2rem;
          height: 2rem;
          border-radius: 50%;
          margin:0;
        }
        h3 {

          font-size: 1rem;
          line-height: 1.125rem;
          padding:0 0 0 0.3125rem;
          text-align: left;
          font-weight: 500;
          color: #00001C;
        }
      }
      .symbol {
        padding:0 0.625rem 0 0;
        // flex:1;
        // display: table-cell;
        // vertical-align: middle;
        .icon-yinhao {
          font-size: 1.375rem;
        }
        span {
          // font-size: 4.375rem;
          color: #F0F0F1;
        }
      }
    }

    .detail {
      padding:0.4375rem 0 0 0;
      font-size: 0.8125rem;
      color: #6E6E79;
      line-height: 1.25rem;
      text-align: left;
    }
  }
  .goods-List {
    display: flex;
    flex-direction: column;
    background: #fff;
    margin: 0 0.75rem 0.75rem 0.75rem;
    border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
    .goods-info {
      padding:0.625rem;
      .info_a {
        display: flex;
        .img {
          width: 6rem;
          height: 6rem;
          overflow: hidden;
          background: #f5f5f5;
          margin-right: 0.625rem;
          border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
          img {
            width: 100%;
            max-width: 100%;
            height: 100%;
            // height: auto;
            display: block;
          }
        }

        .info {
          width: 12.625rem;
          text-align: left;
          padding:0 0.75rem 0 0;
          box-sizing: border-box;

          .name {
            // font-size: 32rpx;
            max-height: 2.5rem;
            // line-height: 1.25rem;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            font-size: 0.875rem;
            line-height: 1.125rem;
            font-weight: 500;
            color: #00001C;
          }
          .price-box {
            padding:0.75rem 0 0 0;
          }
          .price {
            // line-height: 1.875rem;
            span {
              display: block;
            }
            font-size: 1rem;
            color: var(--themeBaseColor);
            line-height: 1.125rem;

            .left {
              color: var(--themeBaseColor);
              font-size: 1rem;
              font-weight: bold;
              margin-right: 0.625rem;

              font {
                font-size: 0.75rem;
              }
            }

            .right {
              color: #8c8c8c;
              font-size: 0.75rem;
              text-decoration: line-through;
            }
          }

          .member {
            display: flex;
            align-items: flex-end;
            justify-content: space-between;
            span {
              font-size: 1rem;
              line-height: 1rem;
            }
          }
        }
        .info-pm {
          padding:0;
        }
      }
      .info-page {
        padding: 0.9375rem 0 0 0.75rem;
      }
    }
  }
  .content_d {
    margin:0.625rem 0.75rem 0 0.75rem;
    background: #fff;
    border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
    h5 {
      padding:0.8125rem  0 0  0;
      text-align: center;
      font-size: 1.125rem;
      line-height: 1.125rem;
      font-weight: bold;
      color: #00001C;
    }
    .d_box {
      .goods_box {
        // border-bottom: solid 0.0625rem #ebebeb;
        padding: 0.875rem 0.625rem;
        display: flex;
        .img {
          width: 6rem;
          height: 6rem;
          overflow: hidden;
          background: #f5f5f5;
          margin-right: 0.625rem;
          border-radius: 0.5rem 0.5rem 0.5rem 0.5rem;
          img {
            width: 100%;
            max-width: 100%;
            height: 100%;
          }
        }

        .info {
          width: 15rem;
          padding:0 0.9375rem 0 0;
          box-sizing: border-box;
          text-align: left;

          .info_a {
            font-size: 0.875rem;
            font-weight: 500;
            color: #00001C;
            max-height: 2.5rem;
            line-height: 1.25rem;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
          }

          .info_b {
            font-size: 1rem;
            color: var(--themeBaseColor);
            margin-top: 0.625rem;
            font-weight: bold;
            .money {
              font-size: 0.75rem;
            }
          }
        }
      }
    }
  }
  .fixed {
    position: fixed;
    bottom: 0;
    width: 23.4375rem;
    height: 3.0625rem;
    line-height: 3.0625rem;
    background: #fff;
    box-shadow: 0 -0.0625rem 0.25rem rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: flex-end;
    z-index: 12;
    .favourable {
      position: absolute;
      left: 0.625rem;
    }
    .buyBtn {
      padding: 0.8125rem 1.75rem;
      line-height: 0.9375rem;
      border-radius: 1.3125rem 1.3125rem 1.3125rem 1.3125rem;
      background: var(--themeBaseColor);
      font-size: 0.9375rem;
      // height: 1.625rem;
      display: flex;
      justify-content: center;
      align-self: center;
      border: solid 0.0313rem var(--themeBaseColor);
      color: #fff;
      margin-right: 0.625rem;
      cursor: pointer;
    }
    .price {
      display: flex;
      align-items: center;
      padding-right: 0.625rem;
      font-size: 0.875rem;
      .money {
        font-size: 0.75rem;
      }
      span {
        font-size: 18px;
        color: var(--themeBaseColor);

        font {
          font-size: 0.875rem;
        }
      }
    }
  }
  .fixed-exchange {
    justify-content:flex-start;
  }
  .exchange {
    width: 21.875rem;
    margin:0 0.75rem;
  }
  
}
</style>